CURRENT_FILES=$(wildcard *.cpp)


SEARCH_DIR=/home/gonghuan/search

INC_DIR=./inc
SRC_DIR=./src

SRC_FILES=$(wildcard $(SRC_DIR)/*.cpp)

WRAPPER_MYSQL_DIR=$(SEARCH_DIR)/wrapper/mysql
WRAPPER_MYSQL_FILES=$(wildcard $(WRAPPER_MYSQL_DIR)/*.cpp)

WRAPPER_PUBLIC_DIR=$(SEARCH_DIR)/wrapper/public
WRAPPER_PUBLIC_FILES=$(wildcard $(WRAPPER_PUBLIC_DIR)/*.cpp)

WRAPPER_SGLOBAL_DIR=$(SEARCH_DIR)/wrapper/sglobal
WRAPPER_SGLOBAL_FILES=$(wildcard $(WRAPPER_SGLOBAL_DIR)/*.cpp)

MY_WEBDOM_DIR=$(SEARCH_DIR)/dom
MY_WEBDOM_FILES=$(wildcard $(MY_WEBDOM_DIR)/*.cpp)

FILES=$(CURRENT_FILES) $(SRC_FILES) \
	$(MY_WEBDOM_FILES)\
	$(WRAPPER_PUBLIC_FILES) $(WRAPPER_MYSQL_FILES) $(WRAPPER_SGLOBAL_FILES)\

ALL_INCL=-I. -I$(INC_DIR) -I$(BOOST_INC) -I$(MYSQL_INC) \
	-I$(MY_WEBDOM_DIR)\
	-I$(WRAPPER_PUBLIC_DIR) -I$(WRAPPER_MYSQL_DIR) -I$(WRAPPER_SGLOBAL_DIR)\
	-I$(HTMLCXX_INC_DIR)

MYSQL_CLIENT_LIB=-L$(MYSQL_LIB) -lmysqlclient

#MYSQL_CLIENT_LIB=-lmysqlclient
BOOST_LIB=-lboost_system
BOOST_REGEX_LIB=-lboost_regex
BOOST_FILE_LIB=-lboost_filesystem
CURL_LIB=-lcurl
PTHREAD_LIB=-lpthread 
HTMLCXX_LIB=-lhtmlcxx
LIBS=$(PTHREAD_LIB) $(BOOST_REGEX_LIB) $(CURL_LIB) $(MYSQL_CLIENT_LIB)\
	$(HTMLCXX_LIB)

DBG=-D_DEBUG

OPR=-g -Wall
CC=g++
CFLAGS=$(OPR)
OBJ=$(FILES:.cpp=.o)

TARGET=a.out

ALL:$(OBJ)
	rm -rf $(TARGET)
	$(CC) -o $(TARGET) $? $(LIBS)

$(OBJ):%.o:%.cpp
	$(CC) $(DBG) $(ALL_INCL) -c $(CFLAGS) $< -o $@

.PHONY:
clean:
	-rm -rf ./$(TARGET) ./*.o $(SRC_DIR)/*.o \
		$(WRAPPER_MYSQL_DIR)/*.o  \
		$(WRAPPER_PUBLIC_DIR)/*.o \
		$(MY_WEBDOM_DIR)/*.o

